// eslint-disable-next-line no-unused-vars
import { Component, CreateElement, VNode } from 'vue'
// eslint-disable-next-line no-unused-vars
import { UnReachable } from '../m-search-table'
import { Observer, typeOf } from '@/shared/Observer'

export function MModal (options) {
  return new Promise(() => {
    Observer.publish('MModalShow', options ?? {})
  })
}

export function defineModal (options) {
  return options
}

export function GETips (options) {
  Object.assign(options, {})
  if (!typeOf(options.default, 'string')) { throw new Error('提示内容需为String') }
  Object.assign(options, {
    carrier: 'dialog',
    width: '550px',
    default: `<div style='text-align:center'><div>${options.default}</div></div>`
  })
  return MModal(options)
}

MModal.close = () => {
  Observer.publish('MModalCloseAll')
}
MModal.back = (invertedNum) => {
  Observer.publish('MModalClose', invertedNum)
}

export default { MModal }
